#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long arr[100010];
int n;
long m;
int main()
{
	while (cin >> n >> m)
	{
		for (int i = 0; i < n; i++)
		{
			cin >> arr[i];
		}
		sort(arr, arr + n);
		int count = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = i+1; j < n; j++)
			{
				if (abs(arr[i] - arr[j]) < m&&arr[i]!=0&&arr[j]!=0)
				{
					count++;
					arr[i] = 666;
					arr[j] = 666;
					break;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}